<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul>
        <li id="moon" class="item">月亮</li>
        <li name = "sun" class="item">太阳</li>
        <li _data = "star" class="item">星星</li>
    </ul>
    <script>
        window.onload = function(){
            var moon = document.getElementById('moon');
            console.log(moon);
            var all = document.getElementsByClassName('item');
            console.log(all);
            var all1 = document.querySelectorAll('.item');
            console.log(all1);
            var sun = document.getElementsByName("sun");
            console.log(sun[0].innerHTML);
        }
        var html = "";
        for(var i = 0 ;i<3;i++){
            html+=`<div>${i}</div>`;
        }
    </script>
</body>
</html>